using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Presentation.Contracts;
using Presentation;
using Globals;

namespace ProjektZespolowy
{
    /// <summary>
    /// Activate User.
    /// </summary>
    public partial class ActivateUser : Page, IActivateUserView
    {
        #region Members

        /// <summary>
        /// Presenter.
        /// </summary>
        private ActivateUserPresenter presenter;

        #endregion Members

        #region Override Methods

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            presenter = new ActivateUserPresenter(this);
        }

        #endregion Override Methods

        #region Private Methods

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["user"]))
            {
                if (!string.IsNullOrEmpty(Request["val"]))
                {
                    //presenter activate account
                    presenter.ActivateUser();
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }

        #endregion Private Methods

        #region IActivateUserView Members

        /// <summary>
        /// Gets or sets the login.
        /// </summary>
        /// <value>The login.</value>
        public string Login_
        {
            get
            {
                return Request["user"];
            }
        }

        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>The password.</value>
        public string Password
        {
            get
            {
                return Request["val"];
            }
        }

        /// <summary>
        /// Displays the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void DisplayMessage(string message)
        {
            lblError.Text = message;
        }

        #endregion
    }
}
